<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="空气污染预测, love &amp; peace">
    <meta name="description" content="空气污染预测摘要作者：胡耀文
本文用北京2010年到2014年气压风向雨雪量等相关物理量的数据集，用LSTM做模型优化，来预测PM2.5浓度。
目前均方差在34左右，还有优化空间。后续会爬取广州的相关天气信息，来预测广州的空气污染程度。
第">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="referrer" content="no-referrer-when-downgrade">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>空气污染预测 | Tokyo Ghoul</title>
    <link rel="icon" type="image/jpeg" href="/jinmuyan.jpg">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery-3.6.0.min.js"></script>

<meta name="generator" content="Hexo 6.0.0">
<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
<link rel="alternate" href="/atom.xml" title="Tokyo Ghoul" type="application/atom+xml">
</head>



   <style>
    body{
       background-image: url(https://cdn.jsdelivr.net/gh/Tokisaki-Galaxy/res/site/medias/background.jpg);
       background-repeat:no-repeat;
       background-size: 100% 100%;
       background-attachment:fixed;
    }
</style>



<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/jinmuyan.jpg" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">Tokyo Ghoul</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/live" class="waves-effect waves-light">
      
      <i class="fas fa-fan" style="zoom: 0.6;"></i>
      
      <span>Live</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/jinmuyan.jpg" class="logo-img circle responsive-img">
        
        <div class="logo-name">Tokyo Ghoul</div>
        <div class="logo-desc">
            
            hi story (not history)
            
        </div>
    </div>

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/live" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-fan"></i>
			
			Live
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/%E5%AE%89%E6%99%BA%E7%84%9517.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">空气污染预测</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/LSTM/">
                                <span class="chip bg-color">LSTM</span>
                            </a>
                        
                            <a href="/tags/%E7%89%B9%E5%BE%81%E9%A2%84%E6%B5%8B/">
                                <span class="chip bg-color">特征预测</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD/" class="post-category">
                                人工智能
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2022-05-17
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
                    2022-05-17
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    2.1k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    7 分
                </div>
                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">

        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <h1 id="空气污染预测"><a href="#空气污染预测" class="headerlink" title="空气污染预测"></a>空气污染预测</h1><h2 id="摘要"><a href="#摘要" class="headerlink" title="摘要"></a>摘要</h2><p>作者：胡耀文</p>
<p>本文用北京2010年到2014年气压风向雨雪量等相关物理量的数据集，用LSTM做模型优化，来预测PM2.5浓度。</p>
<p>目前均方差在34左右，还有优化空间。后续会爬取广州的相关天气信息，来预测广州的空气污染程度。</p>
<h2 id="第一，数据集"><a href="#第一，数据集" class="headerlink" title="第一，数据集"></a>第一，数据集</h2><p><img src="https://img-blog.csdnimg.cn/ce84acf58e204100a2cbdfcb17effac8.png" alt="在这里插入图片描述"></p>
<p>数据集是kaggle上找的，是北京2010年1月1日到2014年12月31日的数据</p>
<p><img src="https://img-blog.csdnimg.cn/0e8b011c399540738da07338e4f422a7.png" alt="在这里插入图片描述"></p>
<p>No是编号</p>
<p>year是年</p>
<p>month是月</p>
<p>day是日</p>
<p>hour是小时</p>
<p>PM2.5是预测值</p>
<p>DEWP是露点</p>
<p>TEMP是温度</p>
<p>PRES是大气压</p>
<p>cbwd是风向</p>
<p>lws是风速</p>
<p>Is是累积雨量</p>
<p>lr是累计雪量</p>
<p>每隔一小时就会采取一次数据</p>
<h3 id="数据预处理"><a href="#数据预处理" class="headerlink" title="数据预处理"></a>数据预处理</h3><ul>
<li><p>对NAN空值如果删掉的话会影响数据集的序列结构，所以这里采取前向填充</p>
</li>
<li><p>删掉编号，将年月日时用datetime压成一维作为唯一索引</p>
</li>
<li><p>风向有4个，用独热编码处理，从而删掉风向cbwd这一特征</p>
</li>
<li><p>至此，总计11个特征，用这11个特征来作为预测指标</p>
</li>
</ul>
<p><img src="https://img-blog.csdnimg.cn/150905a9d63841f2884be2345ed20117.png" alt="在这里插入图片描述"></p>
<h3 id="策略采取"><a href="#策略采取" class="headerlink" title="策略采取"></a>策略采取</h3><p>预测的时候，由于选择过早的数据或者过少的数据都是不对的</p>
<p>比如，仅仅用今天这一天的数据来预测明天的值是不恰的</p>
<p>或者用前一个月的值来预测明天的值也是过于浪费</p>
<p>用前一个星期的值就差不多了</p>
<p>在这里，我用了前五天的数据来预测第六天第24h的数据</p>
<p><img src="https://img-blog.csdnimg.cn/2b11428f911949189363d083a3743b29.png" alt="在这里插入图片描述"></p>
<p>总数据集的百分之80作为训练数据，百分之20作为测试数据</p>
<p>至此，数据集部分处理完毕，</p>
<p>现在让我们看看要预测的PM2.5长啥样</p>
<p>下图是最后1000组PM2.5的数据</p>
<p><img src="https://img-blog.csdnimg.cn/61bc53be76754227bd4d0c331f8a7b59.png" alt="在这里插入图片描述"></p>
<p>（emm如果你在北京为了肺好，建议昼伏夜出hhh~~</p>
<h2 id="第二，模型训练，传统卷积和LSTM的比较"><a href="#第二，模型训练，传统卷积和LSTM的比较" class="headerlink" title="第二，模型训练，传统卷积和LSTM的比较"></a>第二，模型训练，传统卷积和LSTM的比较</h2><p>这是最简单的卷积层</p>
<p><img src="https://img-blog.csdnimg.cn/2c4611cc77e346569d28a2a57afb4867.png" alt="在这里插入图片描述"></p>
<p><img src="https://img-blog.csdnimg.cn/d77e9bc52ed740549f12277e0517701f.png" alt="在这里插入图片描述"></p>
<p>50epoch之后总差值大于在5000，均方差大约在52左右</p>
<p><img src="https://img-blog.csdnimg.cn/cee877a1f6ee4a97896ab4e3a559d26b.png" alt="在这里插入图片描述"></p>
<p>接下来看看LSTM</p>
<p><img src="https://img-blog.csdnimg.cn/90300848f9914597b7e53357763fedb2.png" alt="在这里插入图片描述"></p>
<p>我在看官方文档的时候抄错好几次reduceLROnPlateau！！！！然后很莫名其妙的报了好多错</p>
<p>看来以后还是直接copy文档</p>
<p><img src="https://img-blog.csdnimg.cn/6161ed7c58f34e26985d489f26fa6a97.png" alt="在这里插入图片描述"></p>
<p>我没记错的话LSTM特别的一个地方就是输入到输出这个过程会产生一组序列，叫中间状态，参与下一轮的输入到输出的计算</p>
<p>然后循环产生输出</p>
<p>这种特殊的运算结构让它特别擅长捕捉时间变化的趋势，比如对于星期一这样的数据，星期二会变成这样，对于星期二这样的数据，星期三会变成这样，……..，进而对星期六的数据进行较为精准的预测</p>
<p>我的理解就是：</p>
<p>如果这种时间戳的相对关系是对于要预测的指标是存在某种关系的话，那么LSTM在预测时会把这层关系计算进去，</p>
<p>在同等方法里面会很有优势，但如果根本不存在这种关系的话，就会出现“用了等于没用”的情况，</p>
<p>所以针对不同情况，要搭配不同的模型去计算，去预测，</p>
<p>这也是为什么人工智能行业一直在更迅捷的发展，</p>
<p>因为对于某种特定情况，可能目前为止没有哪一种模型更为契合，那么你就要“设计”一种方法，一种计算方法，</p>
<p>如果跑出来的结果比T0要好，那么你就是新的T0了哈哈</p>
<p>下图是开50epoch的时候跑出来的结果：</p>
<p><img src="https://img-blog.csdnimg.cn/7df975e7ac9543c5a30c104b5e7ff7d7.png" alt="在这里插入图片描述"></p>
<p>最后发现总方差在2966，均方差在34，从结果来看确实更好一点</p>
<p>LSTM使用的时候有两个点要注意一下：</p>
<ul>
<li>LSTM网络接受的是三维数据（batch，时间观测，特征）</li>
<li>堆叠LSTM网络，需要设置return_sequences=True,意思是对每个序列预测结果进行输出</li>
</ul>
<h2 id="第三，模型评价，多组数据预测和单组数据预测"><a href="#第三，模型评价，多组数据预测和单组数据预测" class="headerlink" title="第三，模型评价，多组数据预测和单组数据预测"></a>第三，模型评价，多组数据预测和单组数据预测</h2><p>多组数据预测，可以直接用那把百分之20的test_x</p>
<p><img src="https://img-blog.csdnimg.cn/6776f7b73b0740b8a2ea71abec864996.png" alt="在这里插入图片描述"></p>
<p>最后发现这8732条数据总方差在2966，均方差在34，</p>
<p>对单组数据进行预测</p>
<p><img src="https://img-blog.csdnimg.cn/9b88911e0a9e4a6788d65cb62ca1c97b.png" alt="在这里插入图片描述"></p>
<p>我们用最后的数据来预测2015年1月1日23时的情况</p>
<p><img src="https://img-blog.csdnimg.cn/fc23c3fb5f1f462c9d1cff75d2a7c54a.png" alt="在这里插入图片描述"></p>
<p>跑出来的结果是41</p>
<p>我们现在去官网查看北京历史空气污染数据</p>
<p><img src="https://img-blog.csdnimg.cn/599f0886bcb34af18cef279f8855f7d3.png" alt="在这里插入图片描述"></p>
<p>这里的数据是一整天的平均PM2.5浓度</p>
<p>2015年1月1日 平均浓度是41</p>
<p>2015年1月2日 平均浓度是51</p>
<p>预测1月1日23时的浓度时41</p>
<p>差值较小，跑出来的模型灰常ojbk！</p>
<h2 id="第四，广州天气情况的爬取"><a href="#第四，广州天气情况的爬取" class="headerlink" title="第四，广州天气情况的爬取"></a>第四，广州天气情况的爬取</h2><p>只写了一点点，</p>
<p>爬取中国气象网</p>
<p><a target="_blank" rel="noopener" href="http://www.weather.com.cn/weather1d/101280101.shtml">http://www.weather.com.cn/weather1d/101280101.shtml</a></p>
<p>上面这个网址是广东的天气信息</p>
<p>下面是爬取到当天24h的信息</p>
<p><img src="https://img-blog.csdnimg.cn/7ec34b6162f041a082fa24bb992b2b57.png" alt="在这里插入图片描述"></p>
<p>大约18，19摄氏度这样子，今天看看这个中国气象网有没有骗人。</p>
<h2 id="第五，总结与思考"><a href="#第五，总结与思考" class="headerlink" title="第五，总结与思考"></a>第五，总结与思考</h2><p>只要有相关特征，对某一指标的预测都可以用LSTM网络，都是ok的，</p>
<p>很多小tips都是在当前所学上进行一个小的拓展，</p>
<p>比如我在学openvino的时候，看人脸骨骼关键点检测，用这个东西你可以针对某些特定的关节点进行讨论</p>
<p>来完成一些奇奇怪怪的检测，比如看这个人有没有张嘴，或者看这个人眼睛有没有闭上，然后美其名曰：<br>人类公共场所喧哗检测，网课是否打瞌睡智能检测……</p>
<p>这些都是比较初级的，更高级一点的就是表情检测，导入某些表情参数，通过对人脸的识别判断是angry还是happy还是sad</p>
<p>等等。</p>
<p>回到这个空气污染预测，其实是这些指标能够较为充分的描述和概括PM2.5这个指标，所以有了比较好的预测结果，</p>
<p>预测气温，预测天气，预测空气湿度也是同样的道理，比如说如果是空气湿度，先去百度、知网找一找相关论文，看</p>
<p>空气湿度跟哪些因素有关，然后找一找网上有没有现成数据集，没有的话要去哪里爬取</p>
<p>整合成数据集然后进行特征提取训练……巴拉巴拉一大堆，然后你的一个小项目就水完了。</p>
<p>但很多时候不是一帆风顺的</p>
<p>在写的时候难免会遇到很多坑点</p>
<p>比如新版本有一些奇奇怪怪的错误，你去stack overflow搜的时候看到 “I also meet this problem, </p>
<p>I think what is about the upgrade , I had send email to them but they didnt give me a feedback”</p>
<p>那才是最最崩溃的。</p>
<h3 id="kaggle与colab的区别"><a href="#kaggle与colab的区别" class="headerlink" title="kaggle与colab的区别"></a>kaggle与colab的区别</h3><p>这次的全部代码我都是用colab敲的，自从升级成win11之后，我本地搭建的jupyter notebook跑一点点就宕机了，</p>
<p>昨晚第一次使用colab，给我的感觉就是白嫖真的香！很简约风，免费版的算力只有一般CPU的两倍，付费版的能达到6.5倍</p>
<p>要搭梯子，好不好用取决于你的梯子OK不OK，数据集的话不像kaggle那样自己弄了个dataset平台，很轻量级，</p>
<p>当然要用的话也可以用kaggle提供的API下载。</p>
<p>kaggle的话貌似不用搭梯子，里面有很多现成的数据集可以使用，这一点比colab方便很多，功能比较全更像是一个小型github</p>
<p>唯一的痛点就是要注册，而且真的很麻烦，我当时注册的时候反正就一直verify不成功，网上也没有好的解决方案，然后发邮件</p>
<p>过了十几个小时这样子那边 i am sorry to trouble 巴拉巴拉一大堆，反正终于ok终于注册成功了！</p>
<p>如果有更高追求的话，可以没有colab但不能没有kaggle，还是建议两边都去弄一个号。</p>
<p>最后代码挂在github上，题解报告也挂在了博客里，需要可自取</p>
<p><a target="_blank" rel="noopener" href="https://github.com/hyw200199/AI">hyw200199/AI (github.com)</a></p>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">胡耀文</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://hyw200199.github.io/2022/05/17/kong-qi-wu-ran-yu-ce/">https://hyw200199.github.io/2022/05/17/kong-qi-wu-ran-yu-ce/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/about" target="_blank">胡耀文</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/LSTM/">
                                    <span class="chip bg-color">LSTM</span>
                                </a>
                            
                                <a href="/tags/%E7%89%B9%E5%BE%81%E9%A2%84%E6%B5%8B/">
                                    <span class="chip bg-color">特征预测</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">thank you!!! mua~</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/my_alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/my_wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="far fa-dot-circle"></i>&nbsp;本篇
            </div>
            <div class="card">
                <a href="/2022/05/17/kong-qi-wu-ran-yu-ce/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/%E5%AE%89%E6%99%BA%E7%84%9517.jpg" class="responsive-img" alt="空气污染预测">
                        
                        <span class="card-title">空气污染预测</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2022-05-17
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD/" class="post-category">
                                    人工智能
                                </a>
                            
                            
                        </span>
                    </div>
                </div>

                
                <div class="card-action article-tags">
                    
                    <a href="/tags/LSTM/">
                        <span class="chip bg-color">LSTM</span>
                    </a>
                    
                    <a href="/tags/%E7%89%B9%E5%BE%81%E9%A2%84%E6%B5%8B/">
                        <span class="chip bg-color">特征预测</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2022/05/13/shu-lian-pou-fen/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/%E5%AE%89%E6%99%BA%E7%84%9519.jpg" class="responsive-img" alt="树链剖分">
                        
                        <span class="card-title">树链剖分</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2022-05-13
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E7%AE%97%E6%B3%95/" class="post-category">
                                    算法
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">
                        <span class="chip bg-color">数据结构</span>
                    </a>
                    
                    <a href="/tags/%E6%A0%91%E9%93%BE%E5%89%96%E5%88%86/">
                        <span class="chip bg-color">树链剖分</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    

    <div class="container row center-align"
         style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2022</span>
            
            <a href="/about" target="_blank">��ҫ��</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
                &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                        class="white-color">37.1k</span>
            
            
            
                
            
            
                <span id="busuanzi_container_site_pv">
                &nbsp;|&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;
                    <span id="busuanzi_value_site_pv" class="white-color"></span>
            </span>
            
            
                <span id="busuanzi_container_site_uv">
                &nbsp;|&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;
                    <span id="busuanzi_value_site_uv" class="white-color"></span>
            </span>
            
            <br>

            <!-- 运行天数提醒. -->
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/hyw200199" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:2372847321@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=2372847321" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 2372847321" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>



    <a href="https://weibo.com/huyaowen200199" class="tooltipped" target="_blank" data-tooltip="关注我的微博: https://weibo.com/huyaowen200199" data-position="top" data-delay="50">
        <i class="fab fa-weibo"></i>
    </a>



    <a href="https://www.zhihu.com/people/unravel-7-4-18" class="tooltipped" target="_blank" data-tooltip="关注我的知乎: https://www.zhihu.com/people/unravel-7-4-18" data-position="top" data-delay="50">
        <i class="fab fa-zhihu1">知</i>
    </a>



    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    

    
        
        <script type="text/javascript">
            // 只在桌面版网页启用特效
            var windowWidth = $(window).width();
            if (windowWidth > 768) {
                document.write('<script type="text/javascript" src="/libs/others/sakura.js"><\/script>');
            }
        </script>
    

    <!-- 雪花特效 -->
     
        <script type="text/javascript">
            // 只在桌面版网页启用特效
            var windowWidth = $(window).width();
            if (windowWidth > 768) {
                document.write('<script type="text/javascript" src="/libs/others/snow.js"><\/script>');
            }
        </script>
    

    <!-- 鼠标星星特效 -->
     
        <script type="text/javascript">
            // 只在桌面版网页启用特效
            var windowWidth = $(window).width();
            if (windowWidth > 768) {
                document.write('<script type="text/javascript" src="/libs/others/star.js"><\/script>');
            }
        </script>
    

     
        <script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>
        <script src="/libs/others/TencentCaptcha.js"></script>
        <button id="TencentCaptcha" data-appid="xxxxxxxxxx" data-cbfn="callback" type="button" hidden></button>
    

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    <!--腾讯兔小巢-->
    
    

    

    

    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
